package com.xc.content.controller;

import com.xc.content.bo.CourseTeacherBO;
import com.xc.content.convert.CourseTeacherConverter;
import com.xc.content.dto.CourseTeacherDTO;
import com.xc.content.service.CourseTeacherService;
import com.xc.content.utils.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author: hyacinth
 * @CreateTime: 2025-01-09
 * @Version: 1.0
 */
@RestController
@RequestMapping("/content/teacher")
@Api(value = "课程老师管理接口", tags = "课程老师管理接口")
@Slf4j
public class CourseTeacherController {

    @Resource
    private CourseTeacherService courseTeacherService;

    @ApiOperation(value = "新增课程老师")
    @PostMapping("/addCourseTeacher")
    public ResponseResult<?> addCourseTeacher(@RequestBody CourseTeacherDTO courseTeacherDTO){
        CourseTeacherBO courseTeacherBO = CourseTeacherConverter.INSTANCE.courseTeacherDTOToBO(courseTeacherDTO);
        Boolean isAddCourseTeacher = courseTeacherService.addCourseTeacher(courseTeacherBO);
        return ResponseResult.success(isAddCourseTeacher);
    }

    @ApiOperation(value = "修改课程老师")
    @PostMapping("/updateCourseTeacher")
    public ResponseResult<?> updateCourseTeacher(@RequestBody CourseTeacherDTO courseTeacherDTO){
        CourseTeacherBO courseTeacherBO = CourseTeacherConverter.INSTANCE.courseTeacherDTOToBO(courseTeacherDTO);
        Boolean isUpdateCourseTeacher = courseTeacherService.updateCourseTeacher(courseTeacherBO);
        return ResponseResult.success(isUpdateCourseTeacher);
    }


}
